home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / audio / midi / thru_c.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  1.6 KB  |  71 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include "midi.h"
  18. #include "midiio.h"
  19. #include "malloc.h"
  20. #include "stdio.h"
  21.  
  22. /* Turn your Indigo into the worlds most expensive MIDI thru box! */
  23.  
  24. #define BUFSZ 1
  25.  
  26. main(int argc, char **argv)
  27. {
  28.     MIport *port;  
  29.     MIevent e[BUFSZ];
  30.     MIconfig *c;
  31.     u_int pbuf[2];
  32.     int relative = 0;
  33.     int i = 0;
  34.  
  35.     c = MInewconfig();
  36.  
  37.     if (argc > 1 && strcmp(argv[1],"-r") == 0) {
  38.     relative = 1;
  39.     pbuf[0] = MI_STAMPING;
  40.     pbuf[1] = MIRELSTAMP;
  41.     MIsetparams(c, pbuf, 2);
  42.     }
  43.     
  44.     port = MInewport();
  45.     
  46.     if (MIopen(port, "rw", &c) < 0) {
  47.     perror("open");
  48.     exit(-1);
  49.     }
  50.  
  51.     if (relative)
  52.     MIsetstart(port, (struct timeval *) 0);
  53.     
  54.     while (1) {
  55.     int retval;
  56.     
  57.     if ((retval = MIreceive(port, e, BUFSZ)) < 0)  /* receive 1 event  */
  58.     {
  59.         perror("receive");
  60.         exit(-1);
  61.     }
  62.  
  63.     if (retval > 0)
  64.         retval = MIsend(port, e, retval);
  65.     
  66.     if (retval < 0) {
  67.         exit(-1);
  68.     }
  69.     }
  70. }
  71.